<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        div{
            width: 100px;
            height: 100px;
            border: 1px solid black;
            background: #e5e55e;
        }
    </style>
</head>
<body>
    <div></div>
    <button>改变正方形</button>
</body>
<script src="https://ajax.aspnetcdn.com/ajax/jQuery/jquery-3.6.3.js"></script>
<script>
    $("button").click(function(){
        //获取div元素宽度
        console.log( $("div").width())
        let w = $("div").width()
        //console.($(div).width())
        $("div").width(2*w)
        $("div").height(2*w)
    }) 
</script>
</html>